package cn.hp.service.Impl;

import cn.hp.entity.Announcement;
import cn.hp.mapper.AnnouncementMapper;
import cn.hp.service.AnnouncementService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AnnouncementServiceImpl implements AnnouncementService {
    @Resource
    private AnnouncementMapper announcementMapper;

    @Override
    public List<Announcement> findAnnouncement(Announcement announcement) {
        return announcementMapper.findAnnouncement(announcement);
    }

    @Override
    public PageInfo<Announcement> findAnnouncement(Announcement announcement, int page, int limit) {
        PageHelper.startPage(page, limit);
        List<Announcement> list = announcementMapper.findAnnouncement(announcement);
        return new PageInfo<>(list);
    }

    @Override
    public int insertAnnouncement(Announcement announcement) {
        return announcementMapper.insertAnnouncement(announcement);
    }

    @Override
    public int deleteAnnouncementByID(Integer id) {
        return announcementMapper.deleteAnnouncementByID(id);
    }

    @Override
    public int updateAnnouncement(Announcement announcement) {
        return announcementMapper.updateAnnouncement(announcement);
    }
}